using System;
using UI;
using UnityEngine;
using UnityEngine.UI;

namespace Audio
{
    public class EffectAudio : AudioBase
    {
        private AudioSource _audioSource;


        private void Awake()
        {
            Bind(AudioEvent.PLAY_EFFECT_AUDIO);
        }

        public override void Execute(int eventCode, object message)
        {
            switch (eventCode)
            {
                case AudioEvent.PLAY_EFFECT_AUDIO:
                {
                    PlayEffectAudio(message as string);
                    break;
                }
            }
        }

        private void Start()
        {
            _audioSource = GetComponent<AudioSource>();
        }

        private void PlayEffectAudio(string assectName)
        {
            AudioClip ac = Resources.Load<AudioClip>("Sound/Chat/" + assectName);
            _audioSource.clip = ac;
            _audioSource.Play();
        }
    }
}